package com.yykj.prescription.server.controller;

import com.yykj.common.vo.PageData;
import com.yykj.common.vo.ResultVO;
import com.yykj.prescription.client.dto.PrescriptionDetailDTO;
import com.yykj.prescription.server.dto.prescription.PrescriptionListSearchDTO;
import com.yykj.prescription.server.service.PrescriptionService;
import com.yykj.prescription.server.vo.BackPrescriptionListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "后台-- 处方相关接口")
@RestController
@RequestMapping("/api/back/prescription")
public class BackPrescriptionController {
    @GetMapping("/list/doctor/prescription")
    @ApiOperation("处方 -- 列表")
    public ResultVO<PageData<BackPrescriptionListVO>> listDoctorPrescription(PrescriptionListSearchDTO searchDTO) {
        BeanUtils.copyProperties(searchDTO, searchDTO);
        return ResultVO.success(prescriptionService.listBackPrescription(searchDTO));
    }

    @ApiOperation("处方 -- 明细")
    @GetMapping("/info/{prescriptionId}")
    public ResultVO<PrescriptionDetailDTO> prescriptionInfo(@PathVariable String prescriptionId){
        return ResultVO.success(prescriptionService.prescriptionInfo(prescriptionId));
    }

    private PrescriptionService prescriptionService;

    @Autowired
    public void setPrescriptionService(PrescriptionService prescriptionService) {
        this.prescriptionService = prescriptionService;
    }

}
